<?php

namespace Main\Api\Admin;

class categorys extends adminController
{
    
	// 获取全部分类
    public function getAll(){
        $data['limit'] = 30;
        $data['page'] = 1;
        $data['order'] = 'asc';
        $res = $this->Model->query($data);
        if($res){
            $json = [];
            foreach($res['data'] as $k=>$v){
                $json[$v['cid']] = $v['title'];
            }
            if($json){
                $this->success($json, 'ok');
            }
            $this->success('', 'ok');
        }else{
			$this->success('', 'ok',['count'=>0]);
		}
    }
	
    /**
     * 获取列表
     *
     * @return void
     */
    public function list(){
        $data['limit'] = \FC\input('size',$_GET);
        $data['page'] = \FC\input('page',$_GET);
        $data['order'] = 'desc';
        $data['sname'] = \FC\get('title');
        if($data['sname']){
            $data['skey'] = 'title'; 
        }		
        $res = $this->Model->query($data);
        if($res){
            $count = $res['page']['number'];
            $this->success($res['data'], 'ok',['count'=>$count]);
        }else{
            $this->success('', 'ok',['count'=>0]);
        }
    }
}
